package org.siqisource.webstart.core.widgets.tree.ztree.helper;

import java.util.ArrayList;
import java.util.List;

import org.siqisource.webstart.core.widgets.tree.model.TreeNode;
import org.siqisource.webstart.core.widgets.tree.ztree.model.ZtreeNode;

public class ZtreeHelper {
	public static ZtreeNode getZtreeNode(TreeNode treeNode) {

		ZtreeNode ztreeNode = new ZtreeNode();
		ztreeNode.setId(treeNode.getId());
		ztreeNode.setName(treeNode.getName());
		ztreeNode.setIsParent(!treeNode.getIsLeaf());
		ztreeNode.setpId(treeNode.getParentId());

		return ztreeNode;
	}

	public static List<ZtreeNode> getZtreeNodeList(List<TreeNode> treeNodes) {

		List<ZtreeNode> ztreeNodes = new ArrayList<ZtreeNode>();
		for (TreeNode treeNode : treeNodes) {
			ztreeNodes.add(getZtreeNode(treeNode));
		}

		return ztreeNodes;
	}
}
